#pragma once


#define CHECK_HRESULT(hResult)                  if(FAILED(hResult))  return hResult;
#define CHECK_HRESULT_RETURN(hResult, ret)      if(FAILED(hResult))  return (ret);

#define CHECK_HRESULT_BREAK(hResult)            if(FAILED(hResult))  break;

#define XSAFE_RELEASE(ptr)  \
    do \
    { \
        if((ptr) != NULL) \
        { \
            (ptr)->Release(); \
            (ptr) = NULL; \
        } \
    }while(FALSE);

template < class Des, class Src >
Des any_cast(Src& src)
{
    union
    {
        Src s;
        Des d;
    } data;
    data.s = src;
    return data.d;
}
